\subsection{Ideals in the ring of integers}
\begin{lemma}
    Let \( x \in \mathcal O_L \), where \( L \) is a number field.
    Then \( x \) is a unit in \( \mathcal O_L \) if and only if \( N_{L/\mathbb Q}(x) = \pm 1 \).
    We write \( \mathcal O_L^\star \) for the set of units of \( \mathcal O_L \).
\end{lemma}
\begin{proof}
    If \( x \) is a unit, then as the norm is multiplicative, \( N(x x^{-1}) = 1 \) so \( N(x)N(x^{-1}) = 1 \).
    So \( N(x) = \pm 1 \).
    Conversely, let \( \sigma_1, \dots, \sigma_n \colon L \to \mathbb C \) be the distinct field embeddings.
    Let \( L \subseteq \mathbb C \) be the containment given by \( \sigma_1 \).
    If \( x \in \mathcal O_L \), then \( N(x) = x\sigma_2(x) \dots \sigma_n(x) \).
    So if \( N(x) = \pm 1 \), we have \( \frac{1}{x} = \pm \prod_{i=2}^n \sigma_i(x) \).
    This is a product of algebraic integers, hence an algebraic integer.
    So \( x^{-1} \in \mathcal O_L \).
\end{proof}
Recall that if \( x \in \mathcal O_L \), it is irreducible if it does not factorise as \( ab \) where \( a, b \in \mathcal O_L \) not units.
If \( x = uy \) where \( u \) is a unit, we say \( x \) and \( y \) are associate.
Many number fields have rings of algebraic integers which are not unique factorisation domains.
\begin{example}
    Let \( L = \mathbb Q\qty(\sqrt{-5}) \).
    Here, \( \mathcal O_L = \mathbb Z\qty[\sqrt{-5}] \).
    Note that \( 3 \cdot 7 = \qty(1 + 2\sqrt{-5})\qty(1 - 2\sqrt{-5}) \), and \( N(3) = 9, N(7) = 49, N\qty(1 \pm \sqrt{-5}) = 21 \).
    These are not associates.
    We claim that \( 3, 7, 1 \pm 2 \sqrt{-5} \) are irreducible, so \( \mathcal O_L \) is not a unique factorisation domain.
    If this were not the case, \( 3 = \alpha \overline \alpha \), where \( \alpha = x + y\sqrt{-5} \), but \( N(3) = 9 = N(\alpha) N(\overline \alpha) = N(\alpha)^2 \) so \( N(\alpha) = x^2 + 5y^2 = \pm 3 \), but there are no integer solutions to this equation.
    All of the other factors are similarly irreducible.
\end{example}
\begin{remark}
    In any number field, one can factorise any \( \alpha \in \mathcal O_L \) into a product of irreducibles by induction on \( \abs{N(\alpha)} \), but this factorisation is not in general unique.
    An idea due to Kummer is to measure the failure of unique factorisation by studying ideals \( \mathfrak a \vartriangleleft \mathcal O_L \).
\end{remark}
If \( x_1, \dots, x_n \in \mathcal O_L \), we write \( (x_1, \dots, x_n) \) for the ideal \( \sum x_i \mathcal O_L \) generated by the \( x_i \).
We will consider products of ideals, rather than products of elements.
\begin{definition}
    If \( \mathfrak a, \mathfrak b \vartriangleleft \mathcal O_L \), define
    \[ \mathfrak a + \mathfrak b = \qty{x + y \mid x \in \mathfrak a, y \in \mathfrak b};\quad \mathfrak a \mathfrak b = \qty{\sum_i x_i y_i \midd x_i \in \mathfrak a, y_i \in \mathfrak b} \]
\end{definition}
One can check that this is an ideal, and that products are associative.
\begin{example}
    \( (x_1, \dots, x_n) (y_1, \dots, y_m) = \qty(\qty{x_i y_j \mid 1 \leq i \leq n, 1 \leq j \leq n}) \).
    For instance, \( (x)(y) = (xy) \), so the product of principal ideals is principal.
\end{example}
\begin{example}
    Consider \( \mathbb Z[\sqrt{5}] = \mathcal O_L \), and the ideals \( \mathfrak p_1 = (3, 1 + 2\sqrt{5}), \mathfrak p_2 = (3, 1-2\sqrt{5}) \).
    We obtain \( \mathfrak p_1 \mathfrak p_2 = (9, 3(1-2\sqrt{5}), 3(1+2\sqrt{5}), 21) = (3) \).
    So the ideal \( (3) \) factors as \( \mathfrak p_1 \mathfrak p_2 \) in \( \mathcal O_L \).
    Note that \( 37 = (1 + 2\sqrt{-5})(1 - 2\sqrt{-5}) \), so \( \mathbb Z[\sqrt{5}] \) is not a unique factorisation domain.
\end{example}
Recall that an ideal \( \mathfrak p \vartriangleleft R \) is \emph{prime} if \( \faktor{R}{\mathfrak p} \) is an integral domain, so \( p \neq R \) and for all \( x, y \in R \), \( xy \in \mathfrak p \) implies \( x \in \mathfrak p \) or \( y \in \mathfrak p \).
In this course, we will also define that a prime ideal is nonzero.
\begin{lemma}
    If \( \mathfrak a \vartriangleleft \mathcal O_K \), it contains an integer, and moreover, \( \faktor{\mathcal O_K}{\mathfrak a} \) is a finite abelian group.
\end{lemma}
\begin{proof}
    Let \( \alpha \in \mathfrak a, \alpha \neq 0 \).
    Let \( p_\alpha(x) = x^m + a_{m-1} x^{m-1} + \dots + a_0 \in \mathbb Z[x] \) be its minimal polynomial, and \( a_0 \neq 0 \).
    Then \( a_0 = -\alpha(\alpha^{n-1} + a_{n-1} \alpha^{n-1} + \dots + a_2 \alpha + a_1) \).
    But \( a_0 \in \mathbb Z \), \( \alpha \in \mathfrak a \), and the other factor lies in \( \mathcal O_K \).
    So \( a_0 \in \mathfrak a \) as \( \mathfrak a \) is an ideal.
    Hence \( a_0 \mathcal O_K \subseteq \mathfrak a \), so \( \faktor{\mathcal O_K}{a_0 \mathcal O_K} \) surjects onto \( \faktor{\mathcal O_K}{\mathfrak a} \).
    But for any integer \( d \), \( \faktor{\mathcal O_K}{d\mathcal O_K} = \faktor{\mathbb Z^n}{d\mathbb Z^n} = \qty(\faktor{\mathbb Z}{d\mathbb Z})^n \) is a finite set, so \( \faktor{\mathcal O_K}{\mathfrak a} \) is finite.
\end{proof}
\begin{corollary}
    \( \mathfrak a \simeq \mathbb Z^n \), as \( \mathcal O_K \simeq \mathbb Z^n \) and the quotient is finite.
\end{corollary}
Therefore, nonzero ideals in \( \mathcal O_K \) are isomorphic to \( \mathbb Z^n \) as abelian groups.
\begin{proposition}
    \begin{enumerate}
        \item \( \mathcal O_K \) is an integral domain.
        \item \( \mathcal O_K \) is a Noetherian ring.
        \item \( \mathcal O_K \) is \emph{integrally closed} in \( K \) (which is the field of fractions of \( \mathcal O_K \)): if \( x \in K \) is integral over \( \mathcal O_K \), it lies in \( \mathcal O_K \).
        \item Every (implicitly nonzero) prime ideal is maximal.
        We say that the \emph{Krull dimension} of \( \mathcal O_K \) is 1.
    \end{enumerate}
\end{proposition}
\begin{remark}
    A ring with these four properties is called a \emph{Dedekind domain}.
    Many of the results in this section hold for all Dedekind domains.
\end{remark}
\begin{proof}
    \emph{Part (i).}
    \( \mathcal O_K \subseteq K \), and \( K \) is a field.

    \emph{Part (ii).}
    We have shown that \( \mathcal O_K \simeq \mathbb Z^n \), where \( n = [K : \mathbb Q] \), so \( \mathcal O_K \) is finitely generated as an abelian group, so is certainly finitely generated as a ring.

    \emph{Part (iii).}
    \( \mathcal O_K \) is integral over \( \mathbb Z \) by definition, so if \( x \) is integral over \( \mathcal O_K \), it is integral over \( \mathbb Z \).
    So \( x \) is an algebraic integer, so lies in \( \mathcal O_K \).

    \emph{Part (iv).}
    If \( \mathfrak p \) is a prime ideal, then by the previous lemma \( \faktor{\mathcal O_K}{\mathfrak p} \) is finite and an integral domain, as \( \mathfrak p \) is prime.
    All finite integral domains are fields, hence \( \mathfrak p \) is maximal.
\end{proof}
\begin{example}
    Consider \( R = \mathbb C[X,Y] \).
    Then \( (x) \) is prime but not maximal, since \( (x) \subsetneq (x,y) \).
\end{example}

\subsection{Unique factorisation of ideals}
We aim to show that every ideal in \( \mathcal O_K \) factors uniquely as a product of prime ideals.
\begin{definition}
    \( \mathfrak b \) divides \( \mathfrak a \) if there exists an ideal \( \mathfrak c \) such that \( \mathfrak a = \mathfrak b \mathfrak c \).
    We write \( \mathfrak b \mid \mathfrak a \).
\end{definition}
\begin{example}
    \( (5, 1 + 2\sqrt{5}) \mid (3) \) in \( \mathcal O_{\mathbb Q(\sqrt{-5})} \).
    \( 3\mathbb Z \mid 6\mathbb Z \) as \( 3\mathbb Z \cdot 2\mathbb Z = 6\mathbb Z \).
\end{example}
Note that \( \mathfrak b \mathfrak c \subseteq \mathfrak b \), as \( \mathfrak b \) is an ideal.
So if \( \mathfrak b \mid \mathfrak a \), then \( \mathfrak a \subseteq \mathfrak b \).
We will show the converse, that \( \mathfrak a \subseteq \mathfrak b \) implies \( \mathfrak b \mid \mathfrak a \).
This allows us to prove results about division by using containment.
Note that prime ideals are maximal, which allows us to use the containment relation.
\begin{lemma}
    Let \( \mathfrak p \) be a prime ideal in a ring \( R \), and let \( \mathfrak a, \mathfrak b \vartriangleleft R \) be ideals.
    Then if \( \mathfrak a \mathfrak b \subseteq \mathfrak p \), either \( \mathfrak a \subseteq \mathfrak p \) or \( \mathfrak b \subseteq \mathfrak p \).
\end{lemma}
\begin{proof}
    Otherwise, there exists \( a \in \mathfrak a \setminus \mathfrak p \) and \( b \in \mathfrak b \setminus \mathfrak p \), with \( ab \in \mathfrak p \).
    But \( \mathfrak p \) is prime giving a contradiction.
\end{proof}
\begin{lemma}
    Let \( \mathfrak a \trianglelefteq \mathcal O_K \) be a nonzero ideal.
    Then \( \mathfrak a \) contains a product of prime ideals.
\end{lemma}
\begin{proof}
    Otherwise, as \( \mathcal O_K \) is Noetherian, there exists a ideal \( \mathfrak a \) which is maximal with this property.
    In particular, \( \mathfrak a \) is not prime.
    So there exists \( x, y \in \mathcal O_K \) with \( x \) or \( y \) not in \( \mathfrak a \) but \( xy \in \mathfrak a \).
    So \( \mathfrak a \subsetneq \mathfrak a + (x) \).
    But then, \( \mathfrak a + (x) \) contains a product of prime ideals \( \mathfrak p_1, \dots, \mathfrak p_r \) with \( \mathfrak p_1\dots \mathfrak p_r \subseteq \mathfrak a + (x) \).
    Similarly,  there exist prime ideals \( \mathfrak q_1, \dots \mathfrak q_s \) such that \( \mathfrak q_1 \dots\mathfrak q_s \subseteq \mathfrak a + (y) \).
    Then,
    \[ \mathfrak p_1\dots \mathfrak p_r\mathfrak q_1 \dots\mathfrak q_s \subseteq (\mathfrak a + (x))(\mathfrak a + (y)) = \mathfrak a + (xy) \]
    But \( xy \in \mathfrak a \), giving a contradiction.
\end{proof}
The main proof will use the idea that we can formally introduce the group of fractions of the commutative monoid of ideals.
The object \( \qty{y \in K \mid y\mathfrak a \subseteq \mathcal O_K} \) will represent the inverse of \( \mathfrak a \).
\begin{lemma}
    \begin{enumerate}
        \item Let \( 0 \neq \mathfrak a \trianglelefteq \mathcal O_K \) be an ideal.
        If \( x \in K \) has the property that \( x\mathfrak a \subseteq \mathfrak a \), then \( x \in \mathcal O_K \).
        \item Let \( 0 \neq \mathfrak a \vartriangleleft \mathcal O_K \) be a proper ideal.
        Then, \( \mathcal O_K \subseteq \qty{y \in K \mid y\mathfrak a \subseteq \mathcal O_K} \) contains elements which are not in \( \mathcal O_K \).
        Equivalently, \( \faktor{\qty{y \in K \mid y\mathfrak a \subseteq \mathcal O_K}}{\mathcal O_K} \neq \qty{1} \) as abelian groups.
    \end{enumerate}
\end{lemma}
\begin{example}
    Let \( \mathcal O_K = \mathbb Z \) and \( \mathfrak a = 3\mathbb Z \).
    Then, part (i) shows that if \( \frac{a}{b} \cdot 3 \in \mathbb 3\mathbb Z \), then \( \frac{a}{b} \in \mathbb Z \).
    Part (ii) shows that if \( \frac{a}{b} \cdot 3 \in \mathbb Z \) then \( \frac{a}{b} \in \frac{1}{3}\mathbb Z \); for instance, if \( \frac{a}{b} = \frac{1}{3} \), we have \( \faktor{\frac{1}{3}\mathbb Z}{\mathbb Z} = \faktor{\mathbb Z}{3\mathbb Z} \neq \qty{1} \).
\end{example}
\begin{proof}
    \emph{Part (i).}
    \( \mathfrak a \subseteq \mathcal O_K \) is finitely generated as an abelian group, as it is isomorphic to \( \mathbb Z^n \).
    Let \( \alpha_1, \dots, \alpha_n \) be a \( \mathbb Z \)-basis of \( \mathfrak a \).
    Consider \( m_x \colon \mathfrak a \to \mathfrak a \) given by multiplication by \( x \in K \).
    We write \( x \alpha_i = \sum a_{ij} \alpha_j \), where by assumption, \( a_{ij} \) are integers.
    Hence,
    \[ (xI - A) \begin{pmatrix}
        \alpha_1 \\
        \vdots \\
        \alpha_n
    \end{pmatrix} = 0 \]
    where \( A = (a_{ij}) \).
    So \( \det(xI - A) = 0 \), so \( x \) is integral over \( \mathbb Z \); that is, \( x \in \mathcal O_K \).

    \emph{Part (ii).}
    If this holds for \( \mathfrak a \), it certainly holds for all ideals \( \mathfrak a' \subseteq \mathfrak a \).
    So without loss of generality, let \( \mathfrak a \) be maximal, so \( \mathfrak a = \mathfrak p \) is a prime ideal.
    Let \( \alpha \in \mathfrak p \) be nonzero.
    By the previous lemma, there exist prime ideals \( \mathfrak p_1, \dots, \mathfrak p_r \) such that \( \mathfrak p_1 \dots \mathfrak p_r \subseteq (\alpha) \subseteq \mathfrak p \).
    Suppose that \( r \) is minimal.
    By the first lemma in this subsection, there exists \( i \) such that \( \mathfrak p_i \subseteq \mathfrak p \), and without loss of generality \( i = 1 \).
    So \( \mathfrak p_1 \subseteq \mathfrak p \).
    But \( \mathfrak p_1 \) is maximal, so \( \mathfrak p_1 = \mathfrak p \).

    Since \( r \) is minimal, \( \mathfrak p_2 \dots \mathfrak p_r \subsetneq (\alpha) \).
    Fix \( \beta \in \mathfrak p_2 \dots \mathfrak p_r \setminus (\alpha) \).
    Then \( \beta \mathfrak p \subseteq \mathfrak p (\mathfrak p_2 \dots \mathfrak p_r) \subseteq (\alpha) \), but \( \beta \in (\alpha) \).
    So, dividing by \( \alpha \), we obtain \( \frac{\beta}{\alpha} \mathfrak p \subseteq (1) = \mathcal O_K \), but \( \frac{\beta}{\alpha} \not\in \mathcal O_K \).
\end{proof}
\begin{definition}
    A \emph{fractional ideal} is an \( \mathcal O_K \)-module \( X \) such that \( X \subseteq K \) and \( X \) is finitely generated.
\end{definition}
\( X = \qty{x \in K \mid x\mathfrak a \subseteq \mathcal O_K} \) is an \( \mathcal O_K \)-module.
If \( \alpha \in \mathfrak a \setminus \qty{0} \), then \( \alpha X \subseteq \mathcal O_K = \mathbb Z^n \) where \( n = [K:\mathbb Q] \).
Multiplication by \( \alpha \) is an isomorphism \( X \to \alpha X \), and submodules of \( \mathbb Z^n \) are finitely generated abelian groups, so \( X \) is finitely generated as an abelian group, hence as an \( \mathcal O_K \)-module.
Hence \( X \) is a fractional ideal.
\begin{lemma}
    \( \mathfrak q \subseteq K \) is a fractional ideal if and only if there exists a nonzero constant \( c \in K \) such that \( c\mathfrak q \) is an ideal in \( \mathcal O_K \).
\end{lemma}
\begin{proof}
    Suppose \( c\mathfrak q \) is an ideal.
    Then \( \mathfrak q \subseteq K \), and multiplication by \( c \) is an isomorphism \( \mathfrak q \to c\mathfrak q \) as \( \mathcal O_K \)-modules, so it is finitely generated as \( \mathfrak q \) is.

    Suppose \( \mathfrak q \) is a fractional ideal.
    Then, \( x_1, \dots, x_r \) generate \( \mathfrak q \) as an \( \mathcal O_K \)-module.
    But \( x_i \in K \) so \( x_i = \frac{y_i}{n_i} \) where \( y_i \in \mathcal O_K \), \( n_i \in \mathbb Z \).
    Let \( c \) be the least common multiple of the \( n_i \), and then \( cq \subseteq \mathcal O_K \), and is a submodule of \( \mathcal O_K \), and hence is an ideal.
\end{proof}
\begin{corollary}
    \( \mathfrak q \) is isomorphic to \( \mathbb Z^n \) as an abelian group.
\end{corollary}
\begin{proof}
    We have shown that all nonzero ideals in \( \mathcal O_K \) are isomorphic to \( \mathbb Z^n \) as abelian groups, where \( n = [K:\mathbb Q] \), and multiplication by \( c \) is an isomorphism \( \mathfrak q \to c\mathfrak q \).
\end{proof}
Ideals are sometimes called \emph{integral ideals} to distinguish from fractional ideals.
One can define multiplication of fractional ideals in the same way that we defined it for integral ideals.
\begin{definition}
    A fractional ideal \( \mathfrak q \) is \emph{invertible} if there exists a fractional ideal \( \mathfrak r \) such that \( \mathfrak q\mathfrak r = (1) = \mathcal O_K \).
\end{definition}
\begin{proposition}
    Every nonzero fractional ideal \( \mathfrak q \) is invertible, and its inverse is
    \[ \mathfrak q^{-1} = \qty{x \in K \mid x\mathfrak q \subseteq \mathcal O_K} \]
\end{proposition}
\begin{remark}
    \( \mathfrak q = \frac{1}{n} \mathfrak a, \mathfrak r = \frac{1}{m} \mathfrak b \) where \( \mathfrak a, \mathfrak b \) are integral ideals in \( \mathcal O_K \), and \( n, m \in K^\star \).
    Then \( \mathfrak q\mathfrak r = 1 \) if and only if \( \mathfrak a \mathfrak b = (nm) \).
    Therefore, the proposition is equivalent to the statement that for every \( \mathfrak a \trianglelefteq \mathcal O_K \), there exists an ideal \( \mathfrak b \trianglelefteq \mathcal O_K \) such that \( \mathfrak a \mathfrak b \) is principal.
\end{remark}
\begin{proof}
    \( \mathfrak q \) is invertible if and only if \( \mathfrak a \) is invertible, where \( n\mathfrak q = \mathfrak a \) as above.
    So, without loss of generality, let \( \mathfrak q \) be an integral ideal.
    If the proposition is false, there exists some integral ideal in \( \mathcal O_K \).
    As \( \mathcal O_K \) is Noetherian, there exists a maximal such ideal \( \mathfrak a \neq \mathcal O_K \).
    So every ideal \( \mathfrak a' \supsetneq \mathfrak a \) is invertible.
    Let \( \mathfrak b = \qty{x \in K \mid x\mathfrak a \subseteq \mathcal O_K} \), which is a fractional ideal.
    \( \mathcal O_K \subseteq \mathfrak b \) hence \( \mathfrak a \subseteq \mathfrak a \mathfrak b \).
    If \( \mathfrak a = \mathfrak a \mathfrak b \), then part (i) of a previous lemma implies that \( \mathfrak b \subseteq \mathcal O_K \).
    Part (ii) of the same lemma implies \( \mathfrak b \setminus \mathcal O_K \neq \varnothing \), which is a contradiction.
    So \( \mathfrak a \subsetneq \mathfrak a \mathfrak b \subsetneq \mathcal O_K \).
    Then \( \mathfrak a \mathfrak b \) is invertible by assumption, so \( \mathfrak a \) is invertible, giving a contradiction.
    Finally, \( \mathfrak q^{-1} \subseteq \qty{x \in K \mid x\mathfrak q \subseteq \mathcal O_K} = X \), so \( \mathfrak q \mathfrak q^{-1} = \mathcal O_K \subseteq \mathfrak q X \subseteq \mathcal O_K \), so we have equality: \( \mathfrak q^{-1} = X \).
\end{proof}
\begin{corollary}
    Let \( \mathfrak a, \mathfrak b, \mathfrak c \vartriangleleft \mathcal O_K \) be integral ideals, and let \( \mathfrak c \neq (0) \).
    Then,
    \begin{enumerate}
        \item \( \mathfrak b \subseteq \mathfrak a \iff \mathfrak b \mathfrak c \subseteq \mathfrak a \mathfrak c \);
        \item \( \mathfrak a \mid \mathfrak b \iff \mathfrak a \mathfrak c \mid \mathfrak b \mathfrak c \);
        \item \( \mathfrak a \mid \mathfrak b \iff \mathfrak b \subseteq \mathfrak a \).
    \end{enumerate}
\end{corollary}
\begin{proof}
    The forward direction of parts (i) and (ii) are clear; the backward direction follows from multiplication by \( \mathfrak c^{-1} \).
    The forward direction of part (iii) has already been seen.
    Now, suppose \( \mathfrak b \subseteq \mathfrak a \).
    By the proposition above, there exists \( \mathfrak c \) such that \( \mathfrak a \mathfrak c = (\alpha) \) is principal.
    Then, \( \mathfrak b \subseteq \mathfrak a \) if and only if \( \mathfrak b \mathfrak c \subseteq (\alpha) \) by part (i).
    \( \mathfrak a \mid \mathfrak b \) if and only if \( (\alpha) \mid \mathfrak b \mathfrak c \) by part (ii).
    But if \( \mathfrak b \mathfrak c \) is generated by \( \beta_1, \dots, \beta_r \), \( \mathfrak b \mathfrak c \subseteq (\alpha) \) means that each \( \beta_i \) is divisible by \( \alpha \).
    More precisely, \( \beta_i = \beta_i' \alpha \) for some \( \beta_i' \in \mathcal O_K \).
    So \( (\beta_1, \dots, \beta_r) = (\beta_1', \dots, \beta_r') (\alpha) \) proving part (iii).
\end{proof}
\begin{remark}
    Part (iii) is straightforward if \( \mathfrak a \) is principal, and invertibility via fractional ideals allows us to reduce to this case.
\end{remark}
\begin{theorem}
    Let \( \mathfrak a \vartriangleleft \mathcal O_K \) be a nonzero ideal.
    Then \( \mathfrak a \) can be written uniquely as a product of prime ideals.
\end{theorem}
\begin{proof}
    If \( \mathfrak a \) is not prime, it is not maximal.
    Let \( \mathfrak b \supsetneq \mathfrak a \) be an ideal in \( \mathcal O_K \).
    Then \( \mathfrak a = \mathfrak b \mathfrak c \) for some ideal \( \mathfrak c \) containing \( \mathfrak a \) by part (iii) of the previous corollary.
    We continue factoring in this way.
    As the ring is Noetherian, this process will always terminate, as we produce an ascending chain.

    For uniqueness, we have shown that \( \mathfrak p \mid \mathfrak a \mathfrak b \) implies \( \mathfrak p \mid \mathfrak a \) or \( \mathfrak p \mid \mathfrak b \).
    So if \( \mathfrak p_1 \dots \mathfrak p_r = \mathfrak q_1 \dots \mathfrak q_s \) with \( \mathfrak p_i, \mathfrak q_i \) prime, we have \( \mathfrak p_1 \mid \mathfrak q_i \) for some \( i \).
    So let \( i = 1 \) without loss of generality, so \( \mathfrak q_1 \subseteq \mathfrak p_1 \).
    But \( \mathfrak q_1 \) is maximal, so \( \mathfrak q_1 = \mathfrak p_1 \).
    Multiply by \( \mathfrak p_1^{-1} \) to obtain \( \mathfrak p_2 \dots \mathfrak p_r = \mathfrak q_2 \dots \mathfrak q_s \), then by induction, the \( \mathfrak p_i \) and \( \mathfrak q_i \) match.
\end{proof}
\begin{corollary}
    The nonzero fractional ideals form a group \( I_K \) under multiplication.
    \( I_K \) is the free abelian group generated by the prime ideals \( \mathfrak p \vartriangleleft \mathcal O_K \).
    In other words, any \( \mathfrak q \in I_K \) can be written uniquely as a product of prime ideals and their inverses.
    \( \mathfrak q \in I_K \) is an integral ideal if and only if all of the exponents are nonnegative.
\end{corollary}
\begin{proof}
    Follows from the previous theorem after writing \( \mathfrak q = \mathfrak a \mathfrak b^{-1} \) where \( \mathfrak a, \mathfrak b \trianglelefteq \mathcal O_K \).
\end{proof}

\subsection{Class group}
Observe that we have a map \( K^\star \to I_K \) mapping \( x \) to the principal ideal \( (x) \).
This map is a group homomorphism, as \( \alpha\beta \mapsto (\alpha)(\beta) \).
Its kernel is the set of \( \alpha \in K^\star \) such that \( (\alpha) = (1) = \mathcal O_K \), which is the set \( \mathcal O_K^\star \) of invertible elements of \( \mathcal O_K \).
The image is the set of principal ideals \( P_K \).
\begin{definition}
    The \emph{class group} of a number field \( K \) is \( \mathrm{Cl}_K = \faktor{I_K}{P_K} \), the cokernel of the map \( K^\star \to I_K \).
\end{definition}
If \( \mathfrak a \in I_K \), we write \( [\mathfrak a] \) for its equivalence class in the class group, so \( [\mathfrak a] = [\mathfrak b] \) if and only if there exists \( \gamma \in K^\star \) such that \( \gamma \mathfrak a = \mathfrak b \).
\begin{theorem}
    The following are equivalent.
    \begin{enumerate}
        \item \( \mathcal O_K \) is a principal ideal domain;
        \item \( \mathcal O_K \) is a unique factorisation domain;
        \item \( \mathrm{Cl}_K \) is trivial.
    \end{enumerate}
\end{theorem}
\begin{proof}
    (i) holds if and only if (iii) holds by definition.
    (i) implies (ii) is a general fact from IB Groups, Rings and Modules.
    The proof that (ii) implies (i) remains.
    Let \( \mathfrak p \) be a prime ideal in \( \mathcal O_K \), and \( x \in \mathfrak p \) a nonzero element of this ideal.
    We can factorise \( x \) into irreducibles \( x = \alpha_1 \dots \alpha_r \) uniquely by assumption.
    As \( \mathfrak p \) is prime, some \( \alpha_i \) lies in \( \mathfrak p \).
    Then \( (\alpha_i) \subseteq \mathfrak p \), and as \( \mathcal O_K \) is a unique factorisation domain and \( \alpha_i \) is irreducible, \( (\alpha_i) \) is prime.
    But prime ideals are maximal, so \( (\alpha_i) = \mathfrak p \) as required.
\end{proof}
The following sequence is exact.
% https://q.uiver.app/?q=WzAsNixbMCwwLCIxIl0sWzEsMCwiXFxtYXRoY2FsIE9fS15cXHN0YXIiXSxbMiwwLCJLXlxcc3RhciJdLFszLDAsIklfSyJdLFs0LDAsIlxcbWF0aHJte0NsfV9LIl0sWzUsMCwiMSJdLFswLDFdLFsxLDJdLFsyLDNdLFszLDRdLFs0LDVdXQ==
\[\begin{tikzcd}
	1 & {\mathcal O_K^\star} & {K^\star} & {I_K} & {\mathrm{Cl}_K} & 1
	\arrow[from=1-1, to=1-2]
	\arrow[from=1-2, to=1-3]
	\arrow[from=1-3, to=1-4]
	\arrow[from=1-4, to=1-5]
	\arrow[from=1-5, to=1-6]
\end{tikzcd}\]
We can now state the main theorems of the course, which are:
\begin{enumerate}
    \item the class group is finite;
    \item \( \mathcal O_K^\star \) is the direct product of the roots of unity in \( K \) with \( \mathbb Z^{r+s-1} \).
\end{enumerate}
\begin{example}
    \( (3,1+2\sqrt{5})(3,1-2\sqrt{5}) = (3) \), so \( (3,1+2\sqrt{5}) \) and \( (3,1-2\sqrt{5}) \) are inverse in the class group.
\end{example}
\begin{example}
   Let  \( [L:\mathbb Q] = 2 \), so \( L = \mathbb Q(\sqrt{d}) \) for \( d \in \mathbb Z \), and \( d \not\equiv 1 \) mod 4.
   Let \( \mathfrak a \trianglelefteq \mathcal O_L \), so \( \mathfrak a \simeq \mathbb Z^2 \) giving \( \mathfrak a = (\alpha, \beta) \) as an \( \mathcal O_L \)-module.
   We can always assume \( \beta \in \mathbb Z \).
   Indeed, write \( \alpha = a + b \sqrt{d} \) and \( \beta = a' + b' \sqrt{d} \).
   Assume \( \abs{a} + \abs{a'} \) is minimal, so without loss of generality \( a \geq a' \geq 0 \), and if \( a' \neq 0 \), \( \alpha - \beta \), \( \beta \) has smaller \( \abs{a} + \abs{a'} \).
   % corrected from:
%    Let \( \ell = \gcd(b, b') = mb + m'b' \) where \( m, m' \in \mathbb Z \).
%    Then let
%    \[ \beta' = (m\alpha + m'\beta) \underbrace{\qty(\frac{-b'}{\ell})}_{\in \mathbb Z} + \beta \in \mathbb Z \]
%    Then \( \genset{\alpha, \beta} = \genset{\alpha, \beta'} \).
%     Alternatively, \( \mathcal O_L \cap \mathbb Z \neq \qty{0} \), and we can extend a minimal such set to a basis of \( \mathcal O_L \).
\end{example}
\begin{example}
    In a quadratic field \( \mathfrak a = (\alpha, b) \) where \( b \in \mathbb Z \).
    Then \( (b, \alpha) (b, \overline \alpha) \) is principal.
    \[ \mathfrak a \overline{\mathfrak a} = (b^2, b\alpha, b\overline \alpha, \alpha\overline\alpha) = (b^2, b\alpha, b\underbrace{(\alpha + \overline \alpha)}_{\Tr(\alpha)}, N(\alpha)) = (b\alpha, c) \]
    where \( c = \gcd(b^2, \Tr(\alpha), N(\alpha)) \).
    Let \( x = \frac{b\alpha}{c} \in L^\star \).
    \( \Tr(x) = \frac{b\Tr(\alpha)}{c} \in \mathbb Z \), and \( N(c) = N\qty(\frac{b\alpha}{c}) = \frac{b^2 N(\alpha)}{c^2} = \frac{b^2}{c} \frac{N(\alpha)}{c} \in \mathbb Z \), so \( x \in \mathcal O_L \), giving \( c \mid b\alpha \), so \( \mathfrak a \overline{\mathfrak a} = (c) \).
    In particular, \( (b, \alpha), (b, \overline \alpha) \) are inverse in the class group.
\end{example}

\subsection{Norms of ideals}
\begin{definition}
    Let \( L \) be a number field, and let \( [L:\mathbb Q] = n \).
    Let \( \mathfrak a \trianglelefteq \mathcal O_L \) be a nonzero ideal.
    The \emph{norm} of \( \mathfrak a \) is \( \abs{\faktor{\mathcal O_L}{\mathfrak a}} \).
\end{definition}
By Lagrange's theorem, \( N(\mathfrak a) \cdot 1 = 0 \) in \( \faktor{\mathcal O_L}{\mathfrak a} \).
Hence \( N(\mathfrak a) \in \mathfrak a \cap \mathbb Z \).
\begin{example}
    Let \( p \) be a prime.
    \( N((p)) = \abs{\faktor{\mathbb Z^n}{\qty(p\mathbb Z)^n}} = p^n \).
\end{example}
\begin{proposition}
    Let \( \mathfrak a, \mathfrak b \trianglelefteq \mathcal O_L \) be nonzero ideals.
    Then, \( N(\mathfrak a \mathfrak b) = N(\mathfrak a) N(\mathfrak b) \).
\end{proposition}
\begin{remark}
    By unique factorisation of ideals, it suffices to show that
    \[ N(\mathfrak p_1^{a_1} \dots \mathfrak p_n^{a_n}) = N(\mathfrak p_1)^{a_1} \dots N(\mathfrak p_n)^{a_n} \]
    for \( \mathfrak p_i \) distinct prime ideals.
    To show this, we need that
    \begin{enumerate}
        \item \( \faktor{\mathcal O_L}{\mathfrak p_1^{a_1} \dots \mathfrak p_n^{a_n}} \simeq \faktor{\mathcal O_L}{\mathfrak p_1^{a_1}} \dots \faktor{\mathcal O_L}{\mathfrak p_n^{a_n}} \) by the Chinese remainder theorem.
        \item \( \abs{\faktor{\mathcal O_L}{\mathfrak p^e}} = \abs{\faktor{\mathcal O_L}{\mathfrak p}} \cdot \abs{\faktor{\mathfrak p}{\mathfrak p^2}} \cdots \abs{\faktor{\mathfrak p^{e-1}}{\mathfrak p^e}} \) which is a general fact, and this is equal to \( \abs{\faktor{\mathcal O_L}{\mathfrak p}}^e \) as \( \faktor{\mathfrak p^a}{\mathfrak p^{a+1}} \) is a one-dimensional vector space over the field \( \faktor{\mathcal O_L}{\mathfrak p} \).
        This fact is specific to number fields (or more generally, Dedekind domains).
        For a counterexample, consider \( \mathbb F_p[X,Y] \) and \( \mathfrak p = (x,y) \).
    \end{enumerate}
\end{remark}
The following proof uses the above approach obscurely but quickly.
\begin{proof}
    By unique factorisation it suffices to show the result for \( \mathfrak b = \mathfrak p \) where \( \mathfrak p \) is prime.
    \( \mathfrak a \neq \mathfrak a \mathfrak p \) by unique factorisation, so let \( \alpha \in \mathfrak a \setminus \mathfrak a \mathfrak p \).
    We claim that the homomorphism of abelian groups \( \faktor{\mathcal O_L}{\mathfrak p} \to \faktor{\mathfrak a}{\mathfrak a \mathfrak p} \) mapping \( x \mapsto \alpha x \) is an isomorphism.
    Then,
    \[ \faktor{\mathcal O_L}{\mathfrak a} \simeq \faktor{\qty(\faktor{\mathcal O_L}{\mathfrak a \mathfrak p})}{\qty(\faktor{\mathfrak a}{\mathfrak a\mathfrak p})} \]
    so
    \[ N(\mathfrak a) = \abs{\faktor{\mathcal O_L}{\mathfrak a}} = \frac{N(\mathfrak a\mathfrak p)}{\abs{\faktor{\mathfrak a}{\mathfrak a \mathfrak p}}} \]
    but \( \abs{\faktor{\mathfrak a}{\mathfrak a \mathfrak p}} = \abs{\faktor{\mathcal O_L}{\mathfrak p}} = N(\mathfrak p) \) by the claim, proving the proposition.
    We now prove the claim.

    We show the homomorphism is injective.
    \( (\alpha) \subseteq \mathfrak a \) so \( (\alpha) = \mathfrak a \mathfrak c \) for some \( \mathfrak c \vartriangleleft \mathcal O_L \).
    Suppose \( x \) has \( \alpha x \in \mathfrak a \mathfrak p \), so \( x + \mathfrak p \) is in the kernel.
    Then, \( x \mathfrak a \mathfrak c \subseteq \mathfrak a \mathfrak p \).
    Dividing by \( \mathfrak a \), \( x\mathfrak c \subseteq \mathfrak p \).
    But \( \mathfrak p \) is prime, so \( x \in p \) or \( \mathfrak c \subseteq \mathfrak p \).
    But \( \mathfrak c \subseteq \mathfrak p \) implies \( \alpha \in \mathfrak a \mathfrak p \), contradicting our choice of \( \alpha \).
    So \( x \in \mathfrak p \), so the map is injective as required.

    We show the homomorphism is surjective.
    We want to show \( (\alpha) + \mathfrak a \mathfrak p = \mathfrak a \).
    We know that \( \mathfrak a \mathfrak p \subsetneq (\alpha) + \mathfrak a \mathfrak p \subseteq \mathfrak a \).
    Multiplying by \( \mathfrak a^{-1} \), we obtain
    \[ \mathfrak p \subsetneq ((\alpha) + \mathfrak a \mathfrak p) \mathfrak a^{-1} \subseteq \mathcal O_L \]
    But \( \mathfrak p \) is a prime and hence maximal.
    Therefore, \( ((\alpha) + \mathfrak a \mathfrak p) \mathfrak a^{-1} = \mathcal O_L \), so \( (\alpha) + \mathfrak \mathfrak p = \mathfrak a \), so the map is surjective.
\end{proof}
\begin{lemma}
    Let \( M \subseteq \mathbb Z^n \) be a subgroup.
    Then \( M \simeq \mathbb Z^r \) for some \( 0 \leq r \leq n \).
    Suppose further that \( r = n \).
    Let \( e_1, \dots, e_n \) be a basis of \( \mathbb Z^n \) and \( v_1, \dots, v_n \) be a basis of \( M \) over \( \mathbb Z \).
    Then, \( \abs{\faktor{\mathbb Z^n}{M}} = \det A \) where \( A = (a_{ij}) \) and \( v_j = \sum a_{ij} e_i \).
\end{lemma}
\begin{proof}
    We can choose a basis \( v_1, \dots, v_n \) of \( M \) such that \( A \) is upper triangular.
    Then, \( \abs{\det A} = \abs{a_{11} \dots a_{nn}} \).
\end{proof}
\begin{lemma}
    Let \( \mathfrak a \vartriangleleft \mathcal O_L \) be a nonzero ideal, and \( n = [L : \mathbb Q] \).
    Then,
    \begin{enumerate}
        \item There exist \( \alpha_1, \dots, \alpha_n \in \mathfrak a \) such that \( \mathfrak a = \qty{\sum_{i=1}^n r_i \alpha_i \mid r_i \in \mathbb Z} \), and \( \alpha_1, \dots, \alpha_n \) are a basis of \( L / \mathbb Q \).
        \item For any such \( \alpha_1, \dots, \alpha_n \in \mathfrak a \), \( \Delta(\alpha_1, \dots, \alpha_n) = N(\mathfrak a)^2 D_L \) where \( D_L \) is the discriminant of \( L \), and where \( \Delta(\alpha_1, \dots, \alpha_n) = \det \Tr(\alpha_i \alpha_j) = \qty(\det (\sigma_i \alpha_j))^2 \).
    \end{enumerate}
\end{lemma}
\begin{proof}
    \emph{Part (i).}
    The result holds for \( \mathcal O_L \), and if \( d \in \mathfrak a \) is an integer, such as \( d = N(\mathfrak a) \), then \( d\mathcal O_L \subseteq \mathfrak a \subseteq \mathcal O_L \), so as abelian groups, \( (d\mathbb Z)^n \subseteq \mathfrak a \subseteq \mathbb Z^n \), so \( \mathfrak a \simeq \mathbb Z^n \).

    \emph{Part (ii).}
    Let \( \alpha_1', \dots, \alpha_n' \) be an integral basis of \( \mathcal O_L \).
    Let \( A \) be the change of basis matrix from \( \alpha_1, \dots, \alpha_n \) to \( \alpha_1', \dots, \alpha_n' \).
    Then \( \Delta(\alpha_1, \dots, \alpha_n) = (\det A)^2 \Delta(\alpha_1', \dots, \alpha_n') = \abs{\faktor{\mathcal O_L}{\mathfrak a}}^2 D_L \) by the lemma.
\end{proof}
\begin{corollary}
    If \( \alpha_1, \dots, \alpha_n \) generating \( \mathfrak a \) as a \( \mathbb Z \)-module has \( \Delta(\alpha_1, \dots, \alpha_n) \) square-free, then \( \mathfrak a = \mathcal O_L \) and \( D_L \) is square-free.
    In particular, if \( L = \mathbb Q(\alpha) \) and \( \alpha \in \mathcal O_L \) where the discriminant \( \mathrm{disc}(\alpha) = \Delta(1, \alpha, \dots, \alpha^{n-1}) \) is square-free, then \( \mathbb Z[\alpha] = \mathcal O_L \).
    More generally, if \( \alpha \in \mathcal O_L \) and \( L = \mathbb Q(\alpha) \), and \( d \in \mathbb Z \) is a maximal integer such that \( d^2 \mid \mathrm{disc}(\alpha) \), then \( \mathbb Z[\alpha] \subseteq \mathcal O_L \subseteq \frac{1}{d} \mathbb Z[\alpha] \).
\end{corollary}
\begin{lemma}
    Let \( \alpha \in \mathcal O_L \) be a nonzero algebraic integer.
    Then \( N((\alpha)) = \abs{N_{L/\mathbb Q}(\alpha)} \).
\end{lemma}
\begin{proof}
    Let \( \alpha_1, \dots, \alpha_n \) be an integral basis of \( \mathcal O_L \).
    Consider
    \begin{align*}
        \Delta(\alpha_1\alpha, \dots, \alpha_n\alpha) &= \qty(\det(\sigma_i (\alpha_j \alpha)))^2 \\
        &= \qty(\det((\sigma_i \alpha_j)(\sigma_i \alpha)))^2 \\
        &= \qty(\prod_{i=1}^n \sigma_i(\alpha) \cdot \det (\sigma_i \alpha_j))^2 \\
        &= N(\alpha)^2 \Delta(\alpha_1, \dots, \alpha_n) \\
        &= N(\alpha)^2 D_L
    \end{align*}
    But \( \alpha_1\alpha, \dots, \alpha_n\alpha \) is a basis of \( (\alpha) \), hence this is equal to \( N((\alpha))^2 D_L \).
    So \( N((\alpha))^2 = N_{L/\mathbb Q}(\alpha)^2 \), but \( N((\alpha)) > 0 \), giving the result as required.
\end{proof}

\subsection{Prime ideals}
\begin{lemma}
    Let \( \mathfrak p \vartriangleleft \mathcal O_L \) be a prime ideal.
    Then there exists a unique prime \( p \in \mathbb Z \) such that \( \mathfrak p \mid (p) = p\mathcal O_L \).
    Moreover, \( N(\mathfrak p) = p^f \) for some integer \( 1 \leq f \leq n = [L:\mathbb Q] \).
\end{lemma}
\begin{proof}
    \( \mathfrak p \cap \mathbb Z \) is an ideal in \( \mathbb Z \), hence principal.
    So for some \( p \in \mathbb Z \), \( \mathfrak p \cap \mathbb Z = p \mathbb Z \); we claim \( p \) is prime.
    If \( p = ab \) with \( a, b \in \mathbb Z \), then as \( p \in \mathfrak p \), \( a \) or \( b \) lie in \( \mathfrak p \cap \mathbb Z \), so \( a \) or \( b \) lie in \( p \mathbb Z \), so \( p \mid a \) or \( p \mid b \).
    By factorisation of ideals, \( (p) = \mathfrak p \mathfrak a \) for some \( \mathfrak a \trianglelefteq \mathcal O_L \).
    Taking norms, \( N((p)) = N(\mathfrak p) N(\mathfrak a) \).
    But \( N((p)) = p^n \), so \( N(\mathfrak p) = p^f \) for \( 1 \leq f \leq n \).
\end{proof}
\begin{remark}
    Every prime ideal in \( \mathcal O_L \) is a factor of \( (p) \vartriangleleft \mathbb Z \) where \( p \) is a prime.
    Hence, we can factorise \( (p) \) as \( \mathfrak p_1^{e_1} \dots \mathfrak p_r^{e_r} \) for each prime \( p \in \mathbb Z \) to identify all prime ideals in \( \mathcal O_L \).
\end{remark}
Let \( p \in \mathbb Z \) be a prime.
Consider the map \( q \colon \mathcal O_L \to \faktor{\mathcal O_L}{p\mathcal O_L} \), which is a surjection.
By the isomorphism theorem, there is a bijection \( I \mapsto q^{-1}(I) \) with inverse \( J \mapsto \faktor{J}{(p)} \) between the set of ideals in \( \faktor{\mathcal O_L}{p\mathcal O_L} \) and ideals of \( \mathcal O_L \) containing \( p\mathcal O_L \), or equivalently, ideals \( \mathfrak p \vartriangleleft \mathcal O_L \) with \( \mathfrak p \mid (p) \).
The bijection maps prime ideals to prime ideals.

Under certain assumptions, we can determine the prime ideals in \( \faktor{\mathcal O_L}{(p)} \) exactly.
\begin{theorem}[Dedekind's criteria]
    Let \( \alpha \in \mathcal O_L \) have minimal polynomial \( g(x) \in \mathbb Z[x] \).
    Suppose that \( \mathbb Z[\alpha] \subseteq \mathcal O_L \) has finite index \( \abs{\faktor{\mathcal O_L}{\mathbb Z[\alpha]}} \) not divisible by \( p \).
    Let \( \overline g(x) = g(x) \text{ mod } p \in \mathbb F_p[x] \).
    Let \( \overline g(x) = \overline \varphi_1^{e_1} \dots \overline \varphi_r^{e_r} \) be the factorisation of \( g(x) \) into irreducibles in \( \mathbb F_p[x] \).
    Then \( p\mathcal O_L = (p) = \mathfrak p_1^{e_1} \dots \mathfrak p_r^{e_r} \) where \( \mathfrak p_i = (p, \varphi_i(\alpha)) \) is the prime ideal in \( \mathcal O_L \) where we choose any monic polynomial \( \varphi_i(x) \in \mathbb Z[x] \) which has reduction mod \( p \) equal to \( \overline \varphi_i(x) \).
\end{theorem}
\begin{proof}
    First, we show that each factor \( \overline\varphi_i \) defines a prime ideal in \( \faktor{\mathbb Z[\alpha]}{p\mathbb Z[\alpha]} \).
    We will then relate this to prime ideals in \( \faktor{\mathcal O_L}{p\mathcal O_L} \).
    We have a surjective ring homomorphism \( \mathbb Z[x] \to \faktor{\mathbb F_p[x]}{\overline \varphi_i} \).

    We claim that the kernel of this homomorphism is the ideal generated by \( p, \varphi_i \).
    We can factor the map as \( \mathbb Z[\alpha] \to \mathbb F_p[x] \to \faktor{\mathbb F_p[x]}{\overline \varphi_i} \).
    It is clear that \( p, \varphi_i \) lie in the kernel.
    If \( f \mapsto 0 \), then \( \overline \varphi_i \mid \overline f \) so there exists \( \overline h \in \mathbb F_p[x] \) such that \( \overline f = \overline \varphi_i \overline h \), so \( f = \varphi_i h + p s \) for any lift \( h \) of \( \overline h \) of the same degree.
    So the kernel is precisely \( (p, \varphi_i) \).

    We can alternatively factor the map as \( \mathbb Z[\alpha] \to \faktor{\mathbb Z[x]}{g(x) \mathbb Z[x]} \to \faktor{\mathbb F_p[x]}{\overline \varphi_i} \).
    We claim that the kernel of the map \( \mathbb Z[\alpha] \to \mathbb F_p[\alpha] = \faktor{\mathbb F_p[x]}{\overline \varphi_i} \) is the ideal \( \mathfrak q_i \vartriangleleft \mathbb Z[\alpha] \) generated by \( p, \varphi_i(\alpha) \).
    The proof of this claim is left as an exercise.
    Therefore, \( \faktor{\mathbb Z[\alpha]}{\mathfrak q_i} \simeq \faktor{\mathbb F_p[x]}{\overline \varphi_i(x)} \).
    But \( \overline \varphi_i(x) \) is irreducible by hypothesis, so \( \faktor{\mathbb F_p[x]}{\overline \varphi_i(x)} \) is a field, hence \( \mathfrak q_i \) is a prime ideal.
    Therefore, \( \faktor{\mathbb F_p[x]}{\overline\varphi_i} \simeq \mathbb F_q \) where \( q = p^{f_i} \) is some power of \( p \).
    In particular, \( \abs{\faktor{\mathbb Z[\alpha]}{\mathfrak q_i}} = \abs{\faktor{\mathbb F_p[x]}{\overline\varphi_i(x)}} = p^{f_i} \) where \( f_i = \deg \overline\varphi_i \).

    Now, if \( \mathbb Z[\alpha] = \mathcal O_L \) the first part implies that \( \mathfrak p_i = \mathfrak q_i \) is a prime ideal containing \( p \), and \( N(\mathfrak p_i) = p^{f_i} \).
    Suppose \( p \nmid \abs{\faktor{\mathcal O_L}{\mathbb Z[\alpha]}} \).
    We claim that the inclusion map defines an isomorphism \( \iota \colon \faktor{\mathbb Z[\alpha]}{p\mathbb Z[\alpha]} \to \faktor{\mathcal O_L}{p\mathcal O_L} \).
    This implies that there is a bijection between ideals of \( \faktor{\mathbb Z[\alpha]}{p\mathbb Z[\alpha]} \) and ideals of \( \faktor{\mathcal O_L}{p\mathcal O_L} \).
    Hence, there is a bijection between ideals of \( \mathbb Z[\alpha] \) containing \( p \) and ideals of \( \mathcal O_L \) containing \( p \), where this bijection maps an ideal \( (p, y) \trianglelefteq \mathbb Z[\alpha] \) to \( \mathfrak p \trianglelefteq \mathcal O_L \) generated by the same elements under the inclusion map.
    In other words, it maps an ideal \( \mathfrak q \) to \( \mathfrak q \mathcal O_L \).
    The inverse bijection maps \( \mathfrak p \) to \( \mathfrak p \cap \mathbb Z[\alpha] \).
    Moreover, \( \faktor{\mathcal O_L}{\mathfrak p} \simeq \faktor{\mathbb Z[\alpha]}{\mathfrak p \cap \mathbb Z[\alpha]} \) hence \( N(\mathfrak p_i) = p^{\deg \overline\varphi_i} = p^{f_i} \) for \( \mathfrak p_i \) as above.

    We now prove the claim.
    The map \( \faktor{\mathcal O_L}{\mathbb Z[\alpha]} \to \faktor{\mathcal O_L}{\mathbb Z[\alpha]} \) given by multiplication by \( p \) is an isomorphism.
    It is injective as the kernel is a \( p \)-group so must be trivial, and \( \faktor{\mathcal O_L}{\mathbb Z[\alpha]} \) is a finite abelian group, so this is an isomorphism.
    But the kernel of the map \( \iota \colon \faktor{\mathbb Z[\alpha]}{p\mathbb Z[\alpha]} \to \faktor{\mathcal O_L}{p\mathcal O_L} \) is \( \faktor{\mathbb Z[\alpha] \cap p \mathcal O_L}{p\mathbb Z[\alpha]} \), which is precisely the kernel of the map given by multiplication by \( p \).
    So \( \iota \) is injective.

    \( \iota \) is surjective if \( \mathcal O_L = \mathbb Z[\alpha] + p\mathcal O_L \).
    The map given by multiplication by \( p \) is surjective, so \( \iota \) is indeed surjective, and hence an isomorphism as required.

    We have now constructed prime ideals \( \mathfrak p_i = (p, \varphi_i(\alpha)) \vartriangleleft \mathcal O_L \) containing \( p \) with norm \( N(\mathfrak p_i) = p^{f_i} \) with \( f_i = \deg \overline\varphi_i \).
    We must now show that there are no other ideals containing \( p \).
    Now, \( \mathfrak p_i^{e_i} = (p, \varphi_i(\alpha))^{e_i} \subseteq (p, \varphi_i(\alpha)^{e_i}) \), so
    \[ \mathfrak p_1^{e_1} \dots \mathfrak p_r^{e_r} \subseteq (p, \varphi_1(\alpha)^{e_1}) \dots (p, \varphi_r(\alpha)^{e_r}) \subseteq (p, \varphi_1(\alpha)^{e_1} \dots \varphi_r(\alpha)^{e_r}) \]
    But \( \overline{\varphi_1^{e_1} \dots \varphi_r^{e_r}} = \overline g \), so \( \varphi_1^{e_1} \dots \varphi_r^{e_r} = g + p s \).
    So \( (p, \varphi_1(\alpha)^{e_1} \dots \varphi_r(\alpha)^{e_r}) = (p, g(\alpha)) = (p) \) as \( g(\alpha) = 0 \).
    So \( \mathfrak p_1^{e_1} \dots \mathfrak p_r^{e_r} \subseteq (p) \).
    But \( [L:\mathbb Q] = n = \deg g = \deg \overline g = \sum_{i=1}^r e_i \deg \overline\varphi_i = \sum_{i=1}^r e_i f_i \).
    Taking norms,
    \[ N(\mathfrak p_1^{e_1} \dots \mathfrak p_r^{e_r}) = \prod_{i=1}^r N(\mathfrak p_i)^{e_i} = p^{e_1 f_1 + \dots + e_r f_r} = p^n = N((p)) \]
    One can show that if \( \mathfrak a \subseteq \mathfrak b \) and \( N(\mathfrak a) = N(\mathfrak b) \), then \( \mathfrak a = \mathfrak b \).
    So the two ideals are equal.

    Note that if \( i \neq j \), \( \overline \varphi_i, \overline \varphi_j \) are coprime in \( \mathbb F_p[x] \), so \( \mathfrak p_i + \mathfrak p_j = (p, \varphi_i(\alpha), \varphi_j(\alpha)) \neq \mathfrak p_i \), so \( \mathfrak p_i \neq \mathfrak p_j \).
\end{proof}
Note that since we choose a monic polynomial, \( \deg \varphi_i(x) = \deg \overline \varphi_i(x) \).
Different choices of \( \varphi_i(x) \) give the same ideal as \( p \) is in the ideal.
\( \mathfrak p_i \neq \mathfrak p_j \) if \( i \neq j \), and \( \mathfrak p_1^{e_1} \dots \mathfrak p_r^{e_r} \) is the factorisation of \( (p) \) into irreducibles.
\begin{remark}
    Most \( \alpha \in \mathcal O_L \) have \( \faktor{\mathcal O_L}{\mathbb Z[\alpha]} \) finite, but the condition that \( p \nmid \abs{\faktor{\mathcal O_L}{\mathbb Z[\alpha]}} \) is restrictive.
\end{remark}
\begin{example}
    Let \( L = \mathbb Q(\sqrt{-11}) \), and let us factorise \( (5) \subseteq \mathcal O_L \).
    As \( -11 \equiv 1 \text{ mod } 4 \), \( \mathbb Z[\sqrt{-11}] \neq \mathcal O_L \).
    So \( \mathbb Z[\sqrt{-11}] \) has index 2 in \( \mathcal O_L \), and \( 5 \nmid 2 \), so Dedekind's theorem applies.
    Modulo 5, \( x^2 + 1 = (x-2)(x+2) \), so \( (5) = (5, -2 + \sqrt{-11})(5, -2 - \sqrt{-11}) \).
\end{example}
\begin{example}
    In general, let \( L = \mathbb Q(\sqrt{d}) \) where \( d \) is square free and not equal to zero or one.
    Let \( p \) be an odd prime.
    Then, \( \mathbb Z[\sqrt{d}] \subseteq \mathcal O_L \) has index 1 or 2, and both are coprime to \( p \).
    Factorising \( x^2 - d \) modulo \( p \), there are three cases.
    \begin{itemize}
        \item Suppose there are two distinct roots modulo \( p \) of \( x^2 - d \).
        Then, using the Legendre symbol, \( \qty(\frac{d}{p}) = 1 \).
        In this case, \( x^2 - d = (x-r)(x+r) \) for some \( r \in \mathbb Z \).
        By Dedekind's theorem, \( p = \mathfrak p_1 \mathfrak p_2 \) where \( \mathfrak p_1 = (p, \sqrt{d} - r) \) and \( \mathfrak p_2 = (p, \sqrt{d} + r) \).
        In this case, \( N(\mathfrak p_1) = N(\mathfrak p_2) = p \); we say \( p \) \emph{splits} in \( L/\mathbb Q \).
        \item Suppose \( x^2 - d \) is irreducible modulo \( p \).
        Then \( \qty(\frac{d}{p}) = -1 \).
        \( (p) = \mathfrak p \) is prime; we say \( p \) is \emph{inert} in \( L \).
        \item Suppose \( x^2 - d \) has a repeated root, so \( d \equiv 0 \) modulo \( p \).
        Then \( \qty(\frac{d}{p}) = 0 \).
        In this case, Dedekind's theorem gives \( (p) = \mathfrak p^2 \) where \( \mathfrak p = (p, \sqrt{d}) \).
        We say that \( p \) \emph{ramifies} in \( L \).
    \end{itemize}
\end{example}
Now consider the case \( p = 2 \).
\begin{lemma}
    \( 2 \) splits in \( L \) if and only if \( d \equiv 1 \text{ mod } 8 \).
    \( 2 \) is inert in \( L \) if and only if \( d \equiv 5 \text{ mod } 8 \).
    \( 2 \) ramifies in \( L \) if and only if \( d \equiv 2, 3 \text{ mod } 4 \).
\end{lemma}
\begin{proof}
    If \( d \equiv 1 \text{ mod } 4 \), then \( \mathcal O_L = \mathbb Z[\alpha] \) where \( \alpha = \frac{1}{2}(1+\sqrt{d}) \).
    The minimal polynomial of \( \alpha \) is \( x^2 - x + \frac{1}{4}(1-d) \).
    Reducing modulo 2, if \( d \equiv 1 \text{ mod } 8 \) then this is \( x(x+1) \) so 2 splits.
    If \( d \equiv 5 \text{ mod } 8 \) then this gives \( x^2+x+1 \) which is irreducible, so 2 is inert.
    If \( d \equiv 2, 3 \text{ mod } 4 \), then \( \mathcal O_L = \mathbb Z[\sqrt{d}] \) and \( x^2 - d \) is either \( x^2 \) or \( (x-1)^2 \), which ramifies.
\end{proof}
Recall that \( D_L = 4d \) if \( d \equiv 2, 3 \text{ mod } 4 \), and \( D_L = d \) if \( d \equiv 1 \text{ mod } 4 \).
\begin{corollary}
    Let \( L = \mathbb Q(\sqrt{d}) \).
    \( p \mid D_L \) if and only if \( p \) ramifies in \( L \).
\end{corollary}
\begin{proof}
    Case analysis.
\end{proof}
\begin{definition}
    Let \( (p) = \mathfrak p_1^{e_1} \dots \mathfrak p_r^{e_r} \) be the factorisation of \( (p) \) into irreducibles in \( \mathcal O_L \), where \( p^{f_i} = N(\mathfrak p_i) \).
    We say that
    \begin{itemize}
        \item \( p \) \emph{ramifies} if some \( e_i \) is greater than 1;
        \item \( p \) \emph{is inert} if \( r = 1 \) and \( e_1 = 1 \), so \( (p) \) remains prime;
        \item \( p \) \emph{splits} or \emph{splits completely} if \( r = n \) and \( e_i = f_i = \dots = e_n = f_n = 1 \).
    \end{itemize}
\end{definition}
% cor to dedekind
\begin{corollary}
    Let \( p \) be a prime and \( p < n = [L:\mathbb Q] \).
    Let \( \mathbb Z[\alpha] \subseteq \mathcal O_L \) have finite index coprime to \( p \).
    Then \( p \) does not split completely.
\end{corollary}
\begin{proof}
    Let \( g \) be the minimal polynomial of \( \alpha \).
    Suppose \( p \) splits, so \( g \) has \( n \) distinct roots in \( \mathbb F_p \) by Dedekind's theorem.
    But \( n > p \), so this is not possible.
\end{proof}
\begin{example}
    Let \( L = \mathbb Q(\alpha) \) and \( \alpha \) has minimal polynomial \( x^3 - x^2 - 2x - 8 \).
    On an example sheet, we show that 2 splits completely in \( \mathcal O_L \).
    Hence, for all \( \beta \in \mathcal O_L \setminus \mathbb Z \), \( \mathbb Z[\beta] \subseteq \mathcal O_L \) has even index.
\end{example}
Note that Dedekind's theorem allows for the factorisation of \( (p) \) for all but finitely many \( p \), as if \( \alpha \in \mathcal O_L \) with \( \faktor{\mathcal O_L}{\mathbb Z[\alpha]} \) finite, only finitely many primes \( p \) divide its order.
\begin{theorem}
    For all primes \( p \), we have \( (p) = \mathfrak p_1^{e_1} \dots \mathfrak p_r^{e_r} \) with \( \faktor{\mathcal O_L}{\mathfrak p_i} = \faktor{\mathbb F_p[x]}{\overline\varphi_i(x)} \) where \( \overline\varphi_i \in \mathbb F_p[x] \) is an irreducible polynomial of degree \( f_i \) and \( N(\mathfrak p_i) = p^{f_i} \), and \( \faktor{\mathcal O_L}{p\mathcal O_L} \simeq \prod_{i=1}^r \faktor{\mathbb F_p[x]}{\overline\varphi_i(x)} = \prod_{i=1}^r \mathbb F_{p^{f_i}} \).
\end{theorem}
Dedekind's theorem implies that this holds if there exists \( \alpha \in \mathcal O_L \) with \( p \nmid \abs{\faktor{\mathcal O_L}{\mathbb Z[\alpha]}} < \infty \).
\begin{theorem}
    \( p \) ramifies in \( L \) if and only if \( p \mid D_L \).
\end{theorem}
